﻿using System;
using System.Collections;
using System.Collections.Generic;

namespace Project2.容器
{
    internal class StackStudy
    {
        private static void MainStackStudy(string[] args)
        {
            Stack stack = new Stack();

            for (int i = 0; i < 10; i++)
            {
                stack.Push(i);
            }
            PrintStack(stack);
            Console.WriteLine(stack.Peek());

            Console.WriteLine(stack.Pop());
            Console.WriteLine(stack.Pop());

            Console.WriteLine(stack.Peek());
            PrintStack(stack);
            stack.Clear();
            PrintStack(stack);
            Console.WriteLine(stack.Count);
        }

        private static void PrintStack(Stack stack)
        {
            foreach (var item in stack)
            {
                Console.Write(item + ",  ");
            }
            Console.WriteLine();
        }
    }
}